{% block sw_manufacturer_detail %}
<sw-page class="sw-manufacturer-detail">

    {% block sw_manufacturer_detail_header %}
    <template #smart-bar-header>
        <h2>{{ placeholder(manufacturer, 'name', $tc('sw-manufacturer.detail.textHeadline')) }}</h2>
    </template>

    {% endblock %}

    {% block sw_manufacturer_detail_actions %}
    <template #smart-bar-actions>

        {% block sw_manufacturer_detail_actions_abort %}
        <mt-button
            v-tooltip.bottom="tooltipCancel"
            :disabled="manufacturerIsLoading || undefined"
            variant="secondary"
            size="default"
            @click="onCancel"
        >
            {{ $tc('global.default.cancel') }}
        </mt-button>
        {% endblock %}

        {% block sw_manufacturer_detail_actions_save %}
        <sw-button-process
            v-model:process-success="isSaveSuccessful"
            v-tooltip.bottom="tooltipSave"
            class="sw-manufacturer-detail__save-action"
            :is-loading="isLoading"
            :disabled="isLoading || !acl.can('product_manufacturer.editor') || undefined"
            variant="primary"
            @click.prevent="onSave"
        >
            {{ $tc('sw-manufacturer.detail.buttonSave') }}
        </sw-button-process>
        {% endblock %}

    </template>
    {% endblock %}

    {% block sw_manufacturer_detail_language_switch %}
    <template #language-switch>
        <sw-language-switch
            :disabled="manufacturerId == null || undefined"
            :save-changes-function="saveOnLanguageChange"
            :abort-change-function="abortOnLanguageChange"
            @on-change="onChangeLanguage"
        />
    </template>
    {% endblock %}

    {% block sw_manufacturer_detail_content %}
    <template #content>
        <sw-card-view>
            <template v-if="manufacturerIsLoading">
                <sw-skeleton variant="detail-bold" />
                <sw-skeleton />
            </template>

            <template v-else>

                {% block sw_manufacturer_detail_content_language_info %}
                <sw-language-info
                    :entity-description="placeholder(manufacturer, 'name', $tc('sw-manufacturer.detail.textHeadline'))"
                />
                {% endblock %}

                {% block sw_manufacturer_detail_base_basic_info_card %}
                <mt-card
                    position-identifier="sw-manufacturer-detail-basic-info"
                    :title="$tc('sw-manufacturer.detail.cardTitleManufacturerInfo')"
                >
                    <sw-container
                        class="sw-manufacturer-detail__container"
                        columns="repeat(auto-fit, minmax(250px, 1fr))"
                        gap="0 30px"
                    >
                        <div class="sw-manufacturer-detail__base-info-wrapper">

                            {% block sw_manufacturer_detail_base_info_field_name %}

                            <mt-text-field
                                v-model="manufacturer.name"
                                :label="$tc('sw-manufacturer.detail.labelName')"
                                :placeholder="placeholder(manufacturer, 'name', $tc('sw-manufacturer.detail.placeholderName'))"
                                name="name"
                                validation="required"
                                required
                                :error="manufacturerNameError"
                                :disabled="!acl.can('product_manufacturer.editor') || undefined"
                            />
                            {% endblock %}

                            {% block sw_manufacturer_detail_base_info_field_link %}

                            <mt-text-field
                                v-model="manufacturer.link"
                                :label="$tc('sw-manufacturer.detail.labelLink')"
                                :placeholder="$tc('sw-manufacturer.detail.placeholderLink')"
                                name="link"
                                :disabled="!acl.can('product_manufacturer.editor') || undefined"
                            />
                            {% endblock %}
                        </div>

                        {% block sw_manufacturer_detail_logo_upload %}
                        <sw-upload-listener
                            :upload-tag="mediaUploadTag"
                            auto-upload
                            @media-upload-finish="setMediaItem"
                        />
                        <sw-media-upload-v2
                            class="sw-manufacturer-detail__logo-upload"
                            :source="manufacturer.mediaId"
                            :allow-multi-select="false"
                            variant="regular"
                            :upload-tag="mediaUploadTag"
                            :label="$tc('sw-manufacturer.detail.labelLogo')"
                            :default-folder="manufacturerRepository.entityName"
                            :disabled="!acl.can('product_manufacturer.editor') || undefined"
                            @sw-media-upload-v2-media-upload-success="setMediaItem"
                            @media-drop="onDropMedia"
                            @media-upload-sidebar-open="showMediaModal = true"
                            @media-upload-remove-image="onUnlinkLogo"
                        />

                        <sw-media-modal-v2
                            v-if="showMediaModal"
                            :allow-multi-select="false"
                            :initial-folder-id="mediaDefaultFolderId"
                            :entity-context="manufacturer.getEntityName()"
                            @modal-close="showMediaModal = false"
                            @media-modal-selection-change="onMediaSelectionChange"
                        />
                        {% endblock %}
                    </sw-container>

                    {% block sw_manufacturer_detail_base_info_field_description %}
                    <mt-text-editor
                        v-model="manufacturer.description"
                        :label="$tc('sw-manufacturer.detail.labelDescription')"
                        :placeholder="placeholder(manufacturer, 'description', $tc('sw-manufacturer.detail.placeholderDescription'))"
                        name="description"
                        sanitize-input
                        sanitize-field-name="product_manufacturer_translation.description"
                        :disabled="!acl.can('product_manufacturer.editor') || undefined"
                    />
                    {% endblock %}
                </mt-card>
                {% endblock %}

                {% block sw_manufacturer_detail_custom_field_sets %}
                <mt-card
                    v-if="customFieldSets.length > 0"
                    position-identifier="sw-manufacturer-detail-custom-field-sets"
                    :title="$tc('sw-settings-custom-field.general.mainMenuItemGeneral')"
                    :is-loading="manufacturerIsLoading"
                >
                    <sw-custom-field-set-renderer
                        v-if="manufacturer"
                        :entity="manufacturer"
                        :sets="customFieldSets"
                        :disabled="!acl.can('product_manufacturer.editor') || undefined"
                    />
                </mt-card>
                {% endblock %}
            </template>
        </sw-card-view>
    </template>
    {% endblock %}

    {# @deprecated tag:v6.8.0 - Will be removed without replacement #}
    {% block sw_manufacturer_detail_sidebar %}
    {% endblock %}
</sw-page>
{% endblock %}
